<template>
	<div class="icons">
	<swiper :options="swiperOption">
		<swiper-slide v-for="(page,index) of pages" :key="index">
			<div class="icon" v-for="item of page" :key="item.id">
				<div class="icon-img">
					<img class="icon-img-content" :src="item.imgUrl" alt="">
					
				</div>
				<p class="icon-title">{{item.desc}}</p>
			</div>
		</swiper-slide>
		<div class="swiper-pagination" slot="pagination"></div>
	</swiper>
	</div>
</template>
<script>
export default{
	props:{
		icon:Array
	},
	data(){
		return{
			swiperOption:{
				pagination:'.swiper-pagination',
				autoplay:false,
				loop:true
				
			}
			
		}
	},
	computed:{
		pages(){
			const pages=[];
			this.icon.forEach((item,index)=>{
				const page=Math.floor(index/8);
				if(!pages[page]){
					pages[page]=[];
				}
				pages[page].push(item);

			})
			return pages;
		}
	}
}
</script>
<style lang="scss">
@import '~@/assets/styles/base.scss';
.icons{
	width:100%;
	height: 0;
	overflow: hidden;
	padding-bottom: 50%;
	
}
.icon{
	position: relative;
	overflow: hidden;
	width:25%;
	float: left;
	padding-bottom: 25%;

	border:1px solid #fff;
	box-sizing: border-box;

}
.icon-img{
	position: absolute;
	top:px2rem(4px);
	right:0;
	left:0;
	margin:auto;
	width:px2rem(66px);
	height:px2rem(66px);
}
.icon-img img{
	width:100%;
	height:100%;
}
.icon-title{
	position: absolute;
	width:100%;
	top:px2rem(72px);
	text-align: center;
	font-size: px2rem(8px);
	color:#888;
}
</style>